<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <!-- 满足有些用户在手机端访问的需要 -->

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <title>订单管理</title>
    <!-- 线上环境 -->
    <link rel="stylesheet" href="/static/css/dist/component-min.css">
    <link rel="stylesheet" href="/static/plugins/jbox/jbox-min.css">

    <!--vue-->
    <script src="/static/vue/vue.js"></script>
    <!--element ui-->
    <script src="/static/element/index.js"></script>
    <link rel="stylesheet" href="/static/element/index.css">
    <style>
        .el-table__empty-block {
            height: 0;
        }
    </style>

</head>
<body class="cp-bodybox">
<div id="app">
    <#include "/common/header-fg.html" />

    <div class="container">
        <div class="inner clearfix">
            <#include "/common/left-menu-fg.html" />

            <div class="content-right">
                <h1 class="content-right-title">修改密码</h1>
                <div style="width: 500px">
                    <el-form :model="dataForm" :rules="rules" ref="dataForm" label-width="100px">
                        <el-form-item label="原密码" prop="oldPassword">
                            <el-input v-model="dataForm.oldPassword" type="password"></el-input>
                        </el-form-item>
                        <el-form-item label="新密码" prop="newPassword">
                            <el-input v-model="dataForm.newPassword" type="password"></el-input>
                        </el-form-item>
                        <el-form-item label="重复密码" prop="confirmNewPassword">
                            <el-input v-model="dataForm.confirmNewPassword" type="password"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="savePassword">保 存</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
            <!-- end content-right -->

            <a href="javascript:;" class="btn-leftMenuFold" id="j-btn-leftMenuFold"></a>
        </div>
    </div>
    <!-- end container -->

    <!--gonggao-->

    <!--tip-->
    <div class="footer">© 2017 , Inc. All rights reserved.</div>
    <!-- end footer -->
    <div class="fixedBar" style="right: -78px;">
        <ul>
            <template v-for="(item, index) in leftMenuList">
                <li v-if="index==0" :class="'shopManager' + index + ' cur'"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
                <li v-else :class="'shopManager' + index"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
            </template>
        </ul>
        <a href="javascript:;" class="fixedBar-btn" id="j-fixedBar-btn"></a>
    </div>
    <a href="#" id="j-gotop" class="gotop" title="回到顶部" style="left: 1920.59px;"></a>

</div>
<script src="/static/js/dist/lib-min.js"></script>
<script src="/static/js/dist/list.js"></script>
<script src="/static/js/dist/component-min.js"></script>

<!-- 引入api -->
<script src="/static/js/api.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function(){
            let that = this
            var validatePass = function (rule, value, callback) {
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                } else if (value !== that.dataForm.newPassword) {
                    callback(new Error('两次输入密码不一致!'));
                } else {
                    callback();
                }
            };
            return {
                user: ${(user)!'null'},
                headerNavList: list.headerNavList,
                accountNavList: list.accountNavList,
                leftMenuList: list.menu,
                dataForm: {
                    oldPassword: '',
                    newPassword: '',
                    confirmNewPassword:''
                },
                rules: {
                    oldPassword: [
                        { required: true, message: '请输入原密码', trigger: 'blur' }
                    ],
                    newPassword: [
                        { required: true, message: '请输入新密码', trigger: 'blur' }
                    ],
                    confirmNewPassword: [
                        { validator: validatePass, trigger: 'blur' }
                    ]
                }
            }
        },
        mounted:function () {
        },
        methods: {
            savePassword () {
                let validate = false
                this.$refs.dataForm.validate(function (b) {
                    validate = b
                })
                if (validate) {
                    let that = this
                    let obj = {
                        password: this.dataForm.oldPassword,
                        newPassword: this.dataForm.newPassword
                    }
                    this.http("/user/modifyPassword", obj, function (res) {
                        if (res.status === 200) {
                            that.$alert('修改成功', '提示', {
                                confirmButtonText: '确定',
                                callback: function () {
                                    window.location.href = '/login'
                                }
                            });
                        } else {
                            that.$alert(res.errMsg, '提示', {
                                confirmButtonText: '确定',
                            });
                        }
                    }, function (res) {
                        that.$alert('修改失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    })
                }
            }
        }
    })
</script>

<!-- 20170105 --></body>
</html>